package lx2;

public class Saler extends Thread{
    private static int cnt = 200;

    private static final Object lock = new Object();

    @Override
    public void run() {
        while(true) {
            synchronized (this.lock) {
                if (cnt <= 0) break;
                cnt --;
                System.out.println(this.getName() +  "正在执行  还剩" + cnt + "张票");
                try {
                    Saler.sleep(30);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
}
